home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2005 June
/
ccd0605.iso
/
Software
/
Freeware
/
Programare
/
highlight
/
highlight-W32GUI-2.2-10b-Setup.exe
/
{app}
/
src
/
ASStreamiterator.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
2004-01-31
|
1KB
|
83 lines
#include "compiler_defines.h"
#include "ASStreamIterator.h"
#include <iostream>
#include <fstream>
#include <string>
using namespace astyle;
ASStreamIterator::ASStreamIterator(istream *in)
{
inStream = in;
}
ASStreamIterator::~ASStreamIterator()
{
delete inStream;
}
bool ASStreamIterator::hasMoreLines() const
{
if (*inStream)
return true;
else
return false;
}
/*
string ASStreamIterator::nextLine()
{
char theInChar;
char peekedChar;
int theBufferPosn = 0;
//
// treat '\n', '\r', '\n\r' and '\r\n' as an endline.
//
while (theBufferPosn < 2047 && inStream->get(theInChar))
// while not eof
{
if (theInChar != '\n' && theInChar != '\r')
{
buffer[theBufferPosn] = theInChar;
theBufferPosn++;
}
else
{
peekedChar = inStream->peek();
if (peekedChar != theInChar && (peekedChar == '\r' || peekedChar == '\n') )
{
inStream->get(theInChar);
}
break;
}
}
buffer[theBufferPosn] = '\0';
return string(buffer);
}
*/
string ASStreamIterator::nextLine()
{
char *srcPtr;
char *filterPtr;
inStream->getline(buffer, 2047);
srcPtr = filterPtr = buffer;
while (*srcPtr != 0)
{
if (*srcPtr != '\r')
*filterPtr++ = *srcPtr;
srcPtr++;
}
*filterPtr = 0;
return string(buffer);
}